package com.BigData.app.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.BigData.app.dao.StatisticsMapper;
import com.BigData.app.service.StatisticsService;
@Service
public class StatisticsServiceImpl implements StatisticsService {

	@Autowired
	StatisticsMapper getNovelPointMapper;
	
	@Override
	public List<int[]> getNovelPointService(String dataName, String website,String type) {
		// TODO Auto-generated method stub
		List<HashMap<String, Integer>> ret;
		switch (dataName) {
		case "tuijian":
			ret = getNovelPointMapper.getTuiJianPoint(website,type);
			break;
		case "yuepiao":
			ret = getNovelPointMapper.getYuePiaoPoint(website, type);
			break;
		case "dianji":
			ret = getNovelPointMapper.getDianJiPoint(website, type);
			break;
		case "dashang":
			ret = getNovelPointMapper.getDaShangPoint(website, type);
			break;
		case "xianhua":
			ret = getNovelPointMapper.getXianHuaPoint(website, type);
			break;
		case "jReview":
			ret = getNovelPointMapper.getJReviewPoint(website, type);
			break;
		case "jFavorite":
			ret = getNovelPointMapper.getJFavoritePoint(website, type);
			break;
		case "jGifts":
			ret = getNovelPointMapper.getJGiftsPoint(website, type);
			break;
		case "jPoint":
			ret = getNovelPointMapper.getJPointPoint(website, type);
			break;
		default:
			ret = null;
			break;
		}
		//这步是转换hashmap为int[]
		List<int[]> realRet = new ArrayList<int[]>();
		for(HashMap<String, Integer> i : ret){
			int[] intArr = new int[2];
			intArr[0]=i.get("zishu");
			intArr[1]=i.get(dataName);
			realRet.add(intArr);
		}
		return realRet;
	}
	
	@Override
	public List<String> getWebsite() {
		// TODO Auto-generated method stub
		return getNovelPointMapper.getWebsite();
	}
	@Override
	public List<String>getType(String website) {
		// TODO Auto-generated method stub
		return getNovelPointMapper.getType(website);
	}
	@Override
	public HashMap<String, Object> getReDu(String website, String type) {
		// TODO Auto-generated method stub
		return getNovelPointMapper.getReDu(website, type);
	}

	@Override
	public List<HashMap<String, Object>> getNovelByType(String type) {
		// TODO Auto-generated method stub
		return getNovelPointMapper.getNovelByType(type);
	}
	
}
